<template>
	<div class="comment-content">
		<template v-for="(v,k) in list">
			<div class="comment-item" :key="k" @click="reply(v)" :style="{marginLeft:v.ParentMessageID> 0?'80rpx':'0'}">
				<div class="comment-item-left">
					<image :src="v.UserHeaderUrl ? v.UserHeaderUrl : '../../static/icons/avatar.png'" :class="v.ParentMessageID> 0 ? 'reply' : ''" mode="widthFix">
					</image>
				</div>
				<div class="comment-item-right">
					<div class="comment-item-right-top">{{v.UserName}}</div>
					<div class="comment-item-right-bottom"> <span class="reply">{{v.ParentMessageID> 0?`回复${parent.UserName}：`:''}}</span> <span class="text">{{v.Message}}</span> </div>
					<div class="comment-item-right-date">{{getTime(v.CreateTime)}}</div>
					<div class="tip"><span style="color: #8793a8;">回复</span>｜{{v.ChangShangName}}</div>
				</div>
			</div>
			<comment v-if="v.children && v.children.length > 0" :parent="v" :list="v.children" @reply="reply"></comment>
		</template>
	</div>
</template>

<script>
	export default {
		name: 'comment',
		data() {
			return {

			}
		},
		props: {
			list: {
				type: Array,
				default: []
			},
			parent:{
				type:Object,
				default:()=>{}
			}
		},
		methods: {
			reply(v){
				this.$emit('reply',v)
			},
			getTime(v){
				return this.moment(v).fromNow()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.comment-content {
		margin-top: 30rpx;
		margin-bottom: 60rpx;
		.comment-item {
			display: flex;
			margin-top: 50rpx;
			.comment-item-left {
				image {
					width: 60rpx;
					margin-right: 20rpx;
					// border-radius: 50%;
				}
				.reply{
					width: 30rpx;
					margin-right: 20rpx;
				}
			}

			.comment-item-right {
				flex:1;
				position: relative;
				.comment-item-right-top {
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #686868;
				}

				.comment-item-right-bottom {
					font-size: 32rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
					margin: 10rpx 0 ;
					word-break: break-all;
					.reply{
						display: inline-block;
						font-size: 24rpx;
						color: #686868;
						margin-right: 20rpx;
					}
					.text{
						display: inline-block;
					}
				}
				.comment-item-right-date{
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #999999;
					width:100%;
				}
				.tip{
					position: absolute;
					top: 0rpx;
					right:10rpx;
					font-size: 24rpx;
					color: #333333;
				}
			}
		}
	}
</style>